home *** CD-ROM | disk | FTP | other *** search
/ Champak 146 / (Vol 146) Jan 07 2012.iso / Interface / it.dig / scripts / __Packages / mx / controls / UIScrollBar.as < prev    next >
Encoding:
Text File  |  2012-01-07  |  6.7 KB  |  258 lines

  1. class mx.controls.UIScrollBar extends mx.controls.scrollClasses.ScrollBar
  2. {
  3.    var textField;
  4.    var wasHorizontal;
  5.    var __width;
  6.    var __height;
  7.    var hPosition;
  8.    var hscroll;
  9.    var vPosition;
  10.    var scroll;
  11.    var synchScroll;
  12.    var hScroller;
  13.    var vScroller;
  14.    var onChanged;
  15.    var onScroller;
  16.    var isScrolling;
  17.    var dispatchEvent;
  18.    static var symbolName = "UIScrollBar";
  19.    static var symbolOwner = mx.controls.UIScrollBar;
  20.    var className = "UIScrollBar";
  21.    var clipParameters = {_targetInstanceName:1,horizontal:1};
  22.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.UIScrollBar.prototype.clipParameters);
  23.    static var version = "2.0.2.126";
  24.    function UIScrollBar()
  25.    {
  26.       super();
  27.    }
  28.    function init(Void)
  29.    {
  30.       super.init();
  31.       this.textField.owner = this;
  32.       this.horizontal = this.wasHorizontal;
  33.       if(this.horizontal)
  34.       {
  35.          this.textField == undefined ? super.setSize(this.__width,this.__height) : super.setSize(this.textField._width,16);
  36.       }
  37.       else
  38.       {
  39.          this.textField == undefined ? super.setSize(this.__width,this.__height) : super.setSize(16,this.textField._height);
  40.       }
  41.       if(this.horizontal)
  42.       {
  43.          var _loc3_ = this.__width;
  44.          this.__height = this.__width;
  45.          this.width = _loc3_;
  46.          this.__width = 16;
  47.       }
  48.       this.textField.onScroller = function()
  49.       {
  50.          this.hPosition = this.hscroll;
  51.          this.vPosition = this.scroll - 1;
  52.       };
  53.       if(this._targetInstanceName != undefined)
  54.       {
  55.          this.setScrollTarget(this._targetInstanceName);
  56.          this._targetInstanceName.addListener(this);
  57.       }
  58.    }
  59.    function get _targetInstanceName()
  60.    {
  61.       return this.textField;
  62.    }
  63.    function get height()
  64.    {
  65.       if(this.wasHorizontal)
  66.       {
  67.          return this.__width;
  68.       }
  69.       return this.__height;
  70.    }
  71.    function get width()
  72.    {
  73.       if(this.wasHorizontal)
  74.       {
  75.          return this.__height;
  76.       }
  77.       return this.__width;
  78.    }
  79.    function size(Void)
  80.    {
  81.       super.size();
  82.       this.onTextChanged();
  83.    }
  84.    function draw()
  85.    {
  86.       super.draw();
  87.    }
  88.    function set _targetInstanceName(t)
  89.    {
  90.       if(t == undefined)
  91.       {
  92.          this.textField.removeListener(this);
  93.          delete this.textField[!this.horizontal ? "vScroller" : "hScroller"];
  94.          if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
  95.          {
  96.             this.textField.unwatch("text");
  97.             this.textField.unwatch("htmltext");
  98.          }
  99.       }
  100.       var _loc3_ = this._parent[t];
  101.       this.textField = this._parent[t];
  102.       this.onTextChanged();
  103.    }
  104.    function setSize(w, h)
  105.    {
  106.       if(this.horizontal)
  107.       {
  108.          super.setSize(h,w);
  109.       }
  110.       else
  111.       {
  112.          super.setSize(w,h);
  113.       }
  114.    }
  115.    function onTextChanged(Void)
  116.    {
  117.       if(this.textField == undefined)
  118.       {
  119.          return undefined;
  120.       }
  121.       clearInterval(this.synchScroll);
  122.       if(this.horizontal)
  123.       {
  124.          var _loc2_ = this.textField.hscroll;
  125.          this.setScrollProperties(this.textField._width,0,this.textField.maxhscroll);
  126.          this.scrollPosition = Math.min(_loc2_,this.textField.maxhscroll);
  127.       }
  128.       else
  129.       {
  130.          _loc2_ = this.textField.scroll;
  131.          var _loc3_ = this.textField.bottomScroll - this.textField.scroll;
  132.          this.setScrollProperties(_loc3_,1,this.textField.maxscroll);
  133.          this.scrollPosition = Math.min(_loc2_,this.textField.maxscroll);
  134.       }
  135.    }
  136.    function get horizontal()
  137.    {
  138.       return this.wasHorizontal;
  139.    }
  140.    function set horizontal(v)
  141.    {
  142.       this.wasHorizontal = v;
  143.       if(v and this.initializing)
  144.       {
  145.          if(this._rotation == 90)
  146.          {
  147.             return;
  148.          }
  149.          this._xscale = -100;
  150.          this._rotation = -90;
  151.       }
  152.       if(!this.initializing)
  153.       {
  154.          if(v)
  155.          {
  156.             if(this._rotation == 0)
  157.             {
  158.                this._rotation = -90;
  159.                this._xscale = -100;
  160.             }
  161.          }
  162.          else if(this._rotation == -90)
  163.          {
  164.             this._rotation = 0;
  165.             this._xscale = 100;
  166.          }
  167.       }
  168.    }
  169.    function callback(prop, oldval, newval)
  170.    {
  171.       clearInterval(this.hScroller.synchScroll);
  172.       clearInterval(this.vScroller.synchScroll);
  173.       this.hScroller.synchScroll = setInterval(this.hScroller,"onTextChanged",50);
  174.       this.vScroller.synchScroll = setInterval(this.vScroller,"onTextChanged",50);
  175.       return newval;
  176.    }
  177.    function setScrollTarget(tF)
  178.    {
  179.       if(tF == undefined)
  180.       {
  181.          this.textField.removeListener(this);
  182.          delete this.textField[!this.horizontal ? "vScroller" : "hScroller"];
  183.          if(this.textField.hScroller != undefined && this.textField.vScroller != undefined)
  184.          {
  185.             this.textField.unwatch("text");
  186.             this.textField.unwatch("htmltext");
  187.          }
  188.       }
  189.       this.textField = undefined;
  190.       if(!(tF instanceof TextField))
  191.       {
  192.          return undefined;
  193.       }
  194.       this.textField = tF;
  195.       if(this.horizontal)
  196.       {
  197.          this.textField.hScroller = this;
  198.          this.textField.hScroller.lineScrollSize = 5;
  199.       }
  200.       else
  201.       {
  202.          this.textField.vScroller = this;
  203.          this.textField.vScroller.lineScrollSize = 1;
  204.       }
  205.       this.onTextChanged();
  206.       this.onChanged = function(Void)
  207.       {
  208.          this.onTextChanged();
  209.       };
  210.       this.onScroller = function(Void)
  211.       {
  212.          if(!this.isScrolling)
  213.          {
  214.             if(!this.horizontal)
  215.             {
  216.                this.scrollPosition = this.textField.scroll;
  217.             }
  218.             else
  219.             {
  220.                this.scrollPosition = this.textField.hscroll;
  221.             }
  222.          }
  223.       };
  224.       this.textField.addListener(this);
  225.       this.textField.watch("text",this.callback);
  226.       this.textField.watch("htmlText",this.callback);
  227.    }
  228.    function scrollHandler(Void)
  229.    {
  230.       if(this.horizontal)
  231.       {
  232.          var _loc2_ = this.textField.background;
  233.          this.textField.hscroll = this.scrollPosition;
  234.          this.textField.background = _loc2_;
  235.       }
  236.       else
  237.       {
  238.          this.textField.scroll = this.scrollPosition;
  239.       }
  240.    }
  241.    function setEnabled(enable)
  242.    {
  243.       super.setEnabled(enable);
  244.       if(enable)
  245.       {
  246.          this.textField.addListener(this);
  247.       }
  248.       else
  249.       {
  250.          this.textField.removeListener();
  251.       }
  252.    }
  253.    function dispatchScrollEvent(detail)
  254.    {
  255.       this.dispatchEvent({type:"scroll"});
  256.    }
  257. }
  258.